package in.muton.edushare.components.alertpanel;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.poll.components.PreviewLink;
import in.muton.edushare.poll.components.VoteLink;
import in.muton.edushare.schedules.widgets.DateLabel;
import in.muton.edushare.wicket.models.CayenneModel;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Poll;
import com.edushare.common.vo.UserPoll;

public class PollAlert extends Panel {

	public PollAlert(String id, final Poll model) {
		super(id);
		this.pollModel = new CayenneModel<Poll>(model);
		add(new VoteLink("vote", pollModel));
		add(new Label("title", model.getPollName()
				+ " : "
				+ model.getPollAudi(EduShareSession.get()
						.getSessionORMInterface())));
		
		add(new DateLabel("endDate", model.getPollEndDate(), 0));
		add(new PreviewLink("preview", pollModel));
		add(new Link<Void>("hide") {
			private static final long serialVersionUID = 1714904154032917561L;

			@Override
			public void onClick() {
			}
		}.setVisible(false));
	}

	public PollAlert(String id, final UserPoll model) {
		this(id, model.getPoll());
	}

	private IModel<Poll> pollModel = null;

	private static final long serialVersionUID = 8079941390499545275L;
}
